import { PartialTheme, Theme } from "fish-ui-yy";
/**
 * 
 * @param selector 
 * @param theme 
 * @returns 
 * 这里是更改格式，从theme的纯obj改成根据theme，创建一个css规则，
 * .fish-ui-FishProviderr0 {
 *    --borderRadiusNone: 0;
 *    --borderRadiusSmall: 2px;
 *    略...
 * }
 */
export const createCSSRuleFromTheme = (selector:string,theme:Theme | PartialTheme | undefined)=>{
    debugger
    if(theme){
        const cssRule = (
            Object.keys(theme) as (keyof typeof theme)[]
        ).reduce((cssVars,cssVarItem) =>{
            return `${cssVars}--${cssVarItem}:${theme[cssVarItem]};`
        },"")
        return `${selector} {${cssRule}}`
    }
    return `${selector} {}`
}
